package com.gdkm.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gdkm.po.Yu;
import com.gdkm.service.YuyueService;

@Controller

public class YuyueControler {
	@Autowired
	YuyueService service;

	@RequestMapping("/yuguanli")
	public String yuguanli() {
		return "yuguanli";
	}
	@RequestMapping("/woyu")
	public String woyu() {
		return "woyu";
	}
	@ResponseBody
	@RequestMapping("/ylist2")
	public List get(int y) {
		List<Yu> list2 = service.list2((y - 1) * 8, 8);
		System.out.println(list2.toString());
		return list2;
	}

	@RequestMapping("/ysave")
	public String save(String name, String type, String classes, String data) {
		service.save1(name, type, classes, data);
		return "yuguanli";
	}

	@RequestMapping("/ysave1")
	public String save1(String name, String type, String classes, String data) {
		service.save1(name, type, classes, data);
		return "y";
	}

	@ResponseBody
	@RequestMapping("/ylist")
	public List get(String name, String classes, int y) {

		List<Yu> list = service.list3(name, classes, (y - 1) * 8, 8);
		System.out.println("模糊" + list);
		return list;
	}

	@RequestMapping("/ydel")
	public String del(int id) {
		service.delete1(id);
		return "yuguanli";
	}

	// 更新
	@RequestMapping("/yupdate")
	public String update(Yu stu) {
		service.update(stu);
		System.out.print(stu);
		return "yuguanli";
	}

	@ResponseBody
	@RequestMapping("/wolist")
	public List get(HttpSession session) {
        String name=(String)session.getAttribute("personName");
        System.out.println("名字是"+name);
		List<Yu> list = service.list4(name);
		System.out.println(list);
		return list;
	}
}
